var network = require('network');

var net = network.openNetWorkClient();

var type = net.getType();
var status = net.getStatus();

net.on('connect', function() {
	console.log('wifi connect event');
  /** get cellular info */
  getCellularInfo();
});

net.on('disconnect', function() {
	console.log('wifi disconnect event');
});

/** WiFi 场景 */
// net.connect({
//   ssid: 'aiot',
//   password: '12345678',
//   success: function(){
//     console.log('wifi connected');
//   }
// });

/** 4G模组 场景 */
function getCellularInfo()
{
  var info = net.getInfo();

  /* imsi 国际移动用户识别码 */
  console.log('net imsi is: ' + info.simInfo.imsi);
  
  /* imei 国际移动设备识别码 */
  console.log('net imei is: ' + info.simInfo.imei);
  
  /* iccid 集成电路卡识别码 */
  console.log('net iccid is: ' + info.simInfo.iccid);
  
  /* cid 基站编号 */
  console.log('net cid is: ' + info.locatorInfo.cellid);
  
  /* lac 位置区域码 */
  console.log('net lac is: ' + info.locatorInfo.lac);
  
  /* mcc 移动国家代码（中国的为460 */
  console.log('net mcc is: ' + info.locatorInfo.mcc);
  
  /* mnc 移动网络号码（中国移动为00，中国联通为01） */
  console.log('net mnc is: ' + info.locatorInfo.mnc);
  
  /* rssi 接收的信号强度值 */
  console.log('net rssi is: ' + info.locatorInfo.signal);
}
